﻿@model HinduShop.UI.ViewModels.StoreManager.EditProductViewModel

@{
    ViewBag.Title = "Редактирование: " + Model.ProductName;
}

<h2>Редактирование: @Model.ProductName</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("Edit", "StoreManager", FormMethod.Post, new { enctype = "multipart/form-data" })) { 
    
    
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Продукт</legend>
        <p>
            @Html.HiddenFor(m => m.ProductId)
        </p>

        <p>
            @Html.LabelFor(x => x.ProductName) <br/>
            @Html.TextBoxFor(x => x.ProductName)
        </p>

        <p>
            @Html.LabelFor(x => x.ProductPrice) <br/>
            @Html.TextBoxFor(x => x.ProductPrice)
        </p>

        <p>
            Категория: <br/>
            @Html.ListBoxFor(x => x.CategorySelectList, Model.CategorySelectList)
        </p>

        <div class="editor-label">Image</div>
        <div class="editor-field">
            @if (Model.HasImage == false)
            {
                @:None
            }
            else
            {
                <img width="150" height="150" src="@Url.Action("GetImage", "Product", new { Model.ProductId })" />
            }
            <div>Загрузить изображение: <input type="file" name="Image"/></div>
        </div>

        <input type="submit" value="Записать"/>
    </fieldset>
}

<div>
    @Html.ActionLink("Вернуться к списку", "Index")
</div>
